<?php
/**
 * Created by PhpStorm.
 * User: davin
 * Date: 14-10-19
 * Time: 下午12:03
 *
 * 购物车类
 */

use LaravelBook\Ardent\Ardent;

class Basket extends Ardent{


    public static $relationsData = array(
        'member' => array(self::BELONGS_TO, 'Member', 'foreignKey' => 'member_id', 'otherKey' => 'id'),
        'food' => array(self::BELONGS_TO, 'Food', 'foreignKey' => 'food_id', 'otherKey' => 'id'),
    );


    public static function getFoods($member_id){
        return Basket::with('food')->where('member_id', $member_id)->orderBy('created_at','asc')->get();
    }


}
